package com.lt.bcra.controller.questionnaire;


import com.lt.bcra.entity.BcraPhysiologicalFactors;
import com.lt.bcra.exception.BaseException;
import com.lt.bcra.service.BcraPhysiologicalFactorsService;
import com.lt.bcra.result.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 生理因素表 前端控制器
 * </p>
 *
 * @author LuoTian
 * @since 2022-05-25
 */
@Api(tags = "2.生理因素表")
@CrossOrigin //跨域可以前端配置
@RestController
@RequestMapping("bcra/bcraPhysiologicalFactors")
public class BcraPhysiologicalFactorsController {

    private static Logger log = LoggerFactory.getLogger(BcraPhysiologicalFactorsController.class);

    @Autowired
    private BcraPhysiologicalFactorsService bcraPhysiologicalFactorsService;

    @PostMapping("/creatPhysiologicalFactors")
    @ApiOperation("填写生理因素")
    @ApiParam(value = "bcraPhysiologicalFactors")
    public ResultData creatNew(@RequestBody BcraPhysiologicalFactors bcraPhysiologicalFactors) throws BaseException {
        if (log.isDebugEnabled()) log.debug("创建生理因素表 BcraPhysiologicalFactorsController");

        return bcraPhysiologicalFactorsService.saveModule(bcraPhysiologicalFactors);
    }

    @PostMapping("/updatePhysiologicalFactors")
    @ApiOperation("修改生理因素")
    @ApiParam(value = "bcraPhysiologicalFactors")
    public ResultData update(@RequestBody BcraPhysiologicalFactors bcraPhysiologicalFactors) throws BaseException {
        if (log.isDebugEnabled()) log.debug("修改生理因素表 BcraPhysiologicalFactorsController");

        return bcraPhysiologicalFactorsService.updateModule(bcraPhysiologicalFactors);
    }
    @DeleteMapping("/deletePhysiologicalFactors")
    @ApiOperation("删除生理因素")
    @ApiParam(value = "问卷编号")
    public ResultData delete(String questionnaireCode) throws BaseException{
        if (log.isDebugEnabled()) log.debug("删除生理因素 BcraPhysiologicalFactorsController");

        return bcraPhysiologicalFactorsService.removeByQuesCode(questionnaireCode);
    }
    @GetMapping("/getPhysiologicalFactors")
    @ApiOperation("查看生理因素")
    @ApiParam(value = "问卷编号")
    public ResultData list(String questionnaireCode) throws BaseException{
        if (log.isDebugEnabled()) log.debug("删除生理因素表 BcraPhysiologicalFactorsController");

        return bcraPhysiologicalFactorsService.selectByQuesCode(questionnaireCode);
    }
}

